package study.stream.特化流;

import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @Author 金贵权
 * @Date 2023/6/20 17:30
 **/
public class Demo01 {
    public static void main(String[] args) {
/*        int[] arrInt = {1,2,3,4,5,6,7,8,9,10,11,12,13};
        for (int a : arrInt) {
            Stream<int[]> stream = IntStream.rangeClosed(1, 100).filter(b -> Math.sqrt(a * a + b * b) % 1 == 0).boxed().map(b -> new int[]{a, b, (int) Math.sqrt(a * a + b * b)});
            stream.collect(Collectors.toList()).forEach(x-> System.out.println(Arrays.toString(x)));
        }*/

        Stream<int[]> objectStream =
                IntStream.rangeClosed(1, 100).boxed()
                        .flatMap(a ->
                                IntStream.rangeClosed(a, 100)
                                        .filter(b -> Math.sqrt(a * a + b * b) % 1 == 0)
                                        .mapToObj(b -> new int[]{a, b, (int) Math.sqrt(a * a + b * b)}));
        objectStream.collect(Collectors.toList()).forEach(x -> System.out.println(Arrays.toString(x)));
    }
}
